/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fiap.controler;

import br.com.fiap.modelos.DadosForm;
import br.com.fiap.persistencia.DAOWeb;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Jose Arce - rm64586
 */

@WebServlet (urlPatterns="/processarFormularioSatisfacao")

public class ProcessarSatisfacao extends HttpServlet {

    private DAOWeb persistir = new DAOWeb();
    private Date dataCad = new Date();
    DadosForm satisfacao = new DadosForm();
    
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        
        PrintWriter writer = resp.getWriter();
        
        satisfacao.setNome(req.getParameter("nome"));
        satisfacao.setSexo(req.getParameter("sexo"));
        satisfacao.setComentario(req.getParameter("comentario"));
        satisfacao.setProduto(req.getParameter("produtos"));
        satisfacao.setSatisfacao(req.getParameter("satisfacao"));
        satisfacao.setData(dataCad);
        
        persistir.persistirDados(satisfacao);
        
        writer.println("Cadastrado com Sucesso !!" );
    
        
    }
    
    
    
}
